'''
An example of mixing handlers under process based simulation.

@author: Hatem Oraby
'''
import twistedSim.simManager as simManager 
from twistedSim.contextHandlers import ProcessHandler
from twistedSim.moduleHandler import asyncoreH, twistedH

def main():
    machine = simManager.Machine()

    #Module 1: Time Server
    timeServer = ProcessHandler('asyncServer.py', handler = asyncoreH())
    simManager.SimManager.addModule(timeServer, machine)
    
    #Module 2: Client 
    timeClient = ProcessHandler('twistedClient.py', startTime = 60,
                                handler = twistedH())
    simManager.SimManager.addModule(timeClient, machine)
    
    simManager.SimManager.run()

if __name__ == '__main__':
    main()